package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author: Miyako
 * @Date: 2024-08-03-9:22
 * @Description: bean对象的生命周期
 * 1.实例化bean对象创建
 * 2.属性赋值阶段(依赖注入)
 * 3.初始化阶段 @PostConstruct
 * 4.使用阶段
 * 5.销毁阶段@PreDestroy
 */
@Component
public class Life {
    @Value("file")
    private  String meaning;
    Life(){
        System.out.println("无参");
    }

    Life(int i){
        System.out.println("有参");
    }
    @Value("get")
    public void setMeaning(String meaning) {
        System.out.println(this.meaning);

    }
    @PostConstruct
    public void init(){
        System.out.println("初始化");
    }

    @PreDestroy
    public  void  destroy(){
        System.out.println("销毁方法");
    }
}
